package com.keepers.repair.adapter

import android.widget.Button
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.keepers.repair.R
import com.keepers.repair.model.NotificationModel
import org.jetbrains.anko.*

class NotificationAdapter(layoutResId: Int) : BaseQuickAdapter<NotificationModel, BaseViewHolder>(layoutResId) {
    override fun convert(helper: BaseViewHolder?, item: NotificationModel?) {
        helper?.setText(R.id.item_notification_title, item?.Title)
        helper?.setText(R.id.item_notification_content, item?.Content)
        helper?.setText(R.id.item_notification_time, item?.DataTime)
        helper?.getView<Button>(R.id.item_notification_button)?.setOnClickListener {
            helper.itemView.context.alert {
                title = item?.Title!!
                customView {
                    verticalLayout {
                        textView {
                            setPadding(sp(25), 0, 0, sp(5))
                            text = item.DataTime
                        }
                        scrollView {
                            textView { text = item.Content }
                        }
                    }
                }
                yesButton {}
            }.show()
        }
    }
}
